package org.ruanjj.designmodel.proxymodel;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class LogHandler implements InvocationHandler {
    private Object target;

    public LogHandler(Object target){
        this.target = target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("开始调用方法" + method.getName());
        Object result = method.invoke(target,args);
        System.out.println(method.getName() + "方法调用结束");
        return result;
    }
}
